package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "用户行为API",tags = "用户行为API")
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;
    @ApiOperation("点赞/取消点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult like(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
    @ApiOperation("不喜欢/取消不喜欢")
    @PostMapping("/un_likes_behavior")
    public ResponseResult dislike(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
    @ApiOperation("收藏/取消收藏")
    @PostMapping("/collection_behavior")
    public ResponseResult collect(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @Autowired
    ApReadBehaviorService apReadBehaviorService;
    @ApiOperation("阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody @Validated ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;
    @ApiOperation("文章行为")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArticle(@RequestBody ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
